﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KCMS.BusinessLogic.Interfaces;
using StructureMap;
using AutoMapper;

namespace KCMS.Controllers
{
    public class ContactController : Controller
    {
        //
        // GET: /Contact/
        private IContactService contactService = ObjectFactory.GetInstance<IContactService>();
        public ActionResult Index()
        {
            Guid id = new Guid();
            BusinessLogic.Models.Contact contact = contactService.getById(id);
            var model = Mapper.Map<BusinessLogic.Models.Contact, KCMS.Web.Models.ContactViewModel>(contact);
            return View(model);
        }
        public ActionResult Show(String code)
        {
            BusinessLogic.Models.Contact contact = contactService.getByCode(code);
            var model = Mapper.Map<BusinessLogic.Models.Contact, KCMS.Web.Models.ContactViewModel>(contact);
            return View("Show", model);
        }
        public ActionResult ShowAll()
        {
            IEnumerable<BusinessLogic.Models.Contact> contacts = contactService.getAll();
            var model = Mapper.Map<IEnumerable<BusinessLogic.Models.Contact>, IEnumerable<KCMS.Web.Models.ContactViewModel>>(contacts);
            return View(model);
        }

    }
}
